import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Set;
import java.util.TreeSet;


public class P22 {
	public static void main(String[] args) throws IOException {
		System.out.println("A".getBytes()[0]);
		Set<String> set = new TreeSet<String>();
		
		BufferedReader reader = new BufferedReader(new FileReader(new File("names.txt")));
		String line = reader.readLine();
		reader.close();
		
		String[] names = line.split(",");
		for (int i = 0; i < names.length; i++) {
			set.add(names[i].replaceAll("\"", ""));
			System.out.println(names[i].replaceAll("\"", ""));
		}
		
		
		names = set.toArray(new String[0]);
		long total = 0;
		for (int i = 0; i < names.length; i++) {
			byte[] bytes = names[i].getBytes();
			int sum = 0;
			for (int j = 0; j < bytes.length; j++) {
				sum += bytes[j] - 64;				
			}
			total += (sum * (i + 1));
		}		
		
		System.out.println(total);
		
	}
}
